import { createSlice } from "@reduxjs/toolkit";
import dayjs from "dayjs";
export const counterSlice = createSlice({
  name: "counter",
  initialState: {
    from:'北京',
    tp:'上海',
    isSpeed:false,
    date: dayjs().format("YYYY-MM-DD"),
    ren:[
        {
            name:'张三',
            code:'123458',
            id:1
        },
        {
            name:'张三',
            code:'123458',
            id:1
        },
    ]
  },
  reducers: {
    upFand(state,action){
        state.from=action.payload
        // state.to=action.payload
    },
    upFandT(state,action){
        // state.from=action.payload
        state.to=action.payload
    },
    updATE(state,action){
        // state.from=action.payload
        state.date=action.payload
    },
    upxr(state,action){
        state.ren.push({
            ...action.payload,
            id: new Date().getTime()
        })
    }
  },
});
export const {upFand, upFandT ,upxr,updATE} = counterSlice.actions

export default counterSlice.reducer;
